/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package gek.uni.diplom.ecore.stack.Stack.impl;

import gek.uni.diplom.ecore.stack.Stack.Element;
import gek.uni.diplom.ecore.stack.Stack.Stack;
import gek.uni.diplom.ecore.stack.Stack.StackPackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Element</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link gek.uni.diplom.ecore.stack.Stack.impl.ElementImpl#getVal <em>Val</em>}</li>
 *   <li>{@link gek.uni.diplom.ecore.stack.Stack.impl.ElementImpl#getStack <em>Stack</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ElementImpl extends EObjectImpl implements Element {
	/**
   * The default value of the '{@link #getVal() <em>Val</em>}' attribute.
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @see #getVal()
   * @generated
   * @ordered
   */
	protected static final Integer VAL_EDEFAULT = null;

	/**
   * The cached value of the '{@link #getVal() <em>Val</em>}' attribute.
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @see #getVal()
   * @generated
   * @ordered
   */
	protected Integer val = VAL_EDEFAULT;

	/**
   * The cached value of the '{@link #getStack() <em>Stack</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getStack()
   * @generated
   * @ordered
   */
  protected Stack stack;

  /**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	protected ElementImpl() {
    super();
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	@Override
	protected EClass eStaticClass() {
    return StackPackage.Literals.ELEMENT;
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	public Integer getVal() {
    return val;
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	public void setVal(Integer newVal) {
    Integer oldVal = val;
    val = newVal;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, StackPackage.ELEMENT__VAL, oldVal, val));
  }

	/**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Stack getStack() {
    if (stack != null && stack.eIsProxy()) {
      InternalEObject oldStack = (InternalEObject)stack;
      stack = (Stack)eResolveProxy(oldStack);
      if (stack != oldStack) {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, StackPackage.ELEMENT__STACK, oldStack, stack));
      }
    }
    return stack;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Stack basicGetStack() {
    return stack;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setStack(Stack newStack) {
    Stack oldStack = stack;
    stack = newStack;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, StackPackage.ELEMENT__STACK, oldStack, stack));
  }

  /**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
    switch (featureID) {
      case StackPackage.ELEMENT__VAL:
        return getVal();
      case StackPackage.ELEMENT__STACK:
        if (resolve) return getStack();
        return basicGetStack();
    }
    return super.eGet(featureID, resolve, coreType);
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	@Override
	public void eSet(int featureID, Object newValue) {
    switch (featureID) {
      case StackPackage.ELEMENT__VAL:
        setVal((Integer)newValue);
        return;
      case StackPackage.ELEMENT__STACK:
        setStack((Stack)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	@Override
	public void eUnset(int featureID) {
    switch (featureID) {
      case StackPackage.ELEMENT__VAL:
        setVal(VAL_EDEFAULT);
        return;
      case StackPackage.ELEMENT__STACK:
        setStack((Stack)null);
        return;
    }
    super.eUnset(featureID);
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	@Override
	public boolean eIsSet(int featureID) {
    switch (featureID) {
      case StackPackage.ELEMENT__VAL:
        return VAL_EDEFAULT == null ? val != null : !VAL_EDEFAULT.equals(val);
      case StackPackage.ELEMENT__STACK:
        return stack != null;
    }
    return super.eIsSet(featureID);
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	@Override
	public String toString() {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (val: ");
    result.append(val);
    result.append(')');
    return result.toString();
  }

} //ElementImpl
